package com.liusy.serachengine;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexableField;



/**
 * 
 * 索引转换模型抽像类，包括搜索任务
 * 
 * @author liusy 2013-03-25
 *
 */
public abstract class AbstractConvertModel implements IConvertModel {

	private boolean flag = false;
	
	public Map<String, Object> DocConvertMap(Document doc) {
		List<IndexableField> listField = doc.getFields();
		Map<String,Object> map = new HashMap<String,Object>();
		for (int j = 0; j < listField.size(); j++) {
			IndexableField indexfield = listField.get(j);
			//indexfield.fieldType().docValueType()//.NUMERIC
			map.put(indexfield.name(), indexfield.stringValue());
		}
		return map;
	}
	
	public boolean isFinish()
	{
		return flag;
	}
	
	public void complete()
	{
		this.flag = true;
	}
}
